package com.baizhi.controller;


import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class DemoController {


    @GetMapping("/demo")
    @HystrixCommand(fallbackMethod = "fallbackMethod")
    public String hystrixDemo(Integer id){
        System.out.println("demo ok");
        if(id <= 0){
            throw new RuntimeException("");
        }
        return "hystrixDemo ok";
    }

    public String fallbackMethod(Integer id){
        //log.info("当前服务不可用,已经被熔断掉");
        return "当前服务不可用,已经被熔断掉";
    }
}
